package com.wowudi.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wowudi.entity.DoctorAdviceItems;
import com.wowudi.mapper.DoctorAdviceItemsMapper;
import org.apache.ibatis.annotations.Options;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wowudi.mapper.DoctorAdviceMapper;
import com.wowudi.entity.DoctorAdvice;
import com.wowudi.service.DoctorAdviceService;
@Service
public class DoctorAdviceServiceImpl extends ServiceImpl<DoctorAdviceMapper, DoctorAdvice> implements DoctorAdviceService{
    @Autowired
    private DoctorAdviceMapper doctorAdviceMapper;
    @Autowired
    private DoctorAdviceItemsMapper doctorAdviceItemsMapper;
    @Override
    public Page<DoctorAdvice> getAllBynameandid(Page<DoctorAdvice> page, String cartid, String patiname) {
        return this.doctorAdviceMapper.getAllBynameandid(page,cartid,patiname);
    }

    @Override
    @Options(useGeneratedKeys = true, keyProperty = "da_id", keyColumn = "daId")
    public Integer addDoct(DoctorAdvice doctorAdvice,  int[] aa) {
        Integer id=this.doctorAdviceMapper.insert(doctorAdvice);
        System.out.println("患者id"+id);
        for(int i=0;i<aa.length;i++){
            DoctorAdviceItems doctorAdviceItems=new DoctorAdviceItems();
            doctorAdviceItems.setDId(aa[i]);
            doctorAdviceItems.setDaId(id);
            doctorAdviceItems.setDaiIsdel(0);
            this.doctorAdviceItemsMapper.insert(doctorAdviceItems);
        }
        return id;
    }
}
